class Solution {
    public int numDecodings(String s) {
        int n=s.length();
        char[] ss=s.toCharArray();
        int[] dp=new int[n+1];
        dp[0]=1;
        if(ss[0]!='0') dp[1]=1;
        for(int i=2;i<=n;i++){
            if(ss[i-1]!='0') dp[i]+=dp[i-1];       
            int t=(ss[i-2]-'0')*10+ss[i-1]-'0';
            if(10<=t&&t<=26) dp[i]+=dp[i-2];
        }
        return dp[n];
    }
}